﻿using GCC.Container.PluginLoader;

namespace GCC.APIContainer.APIModels
{
    /// <summary>
    /// 获取插件信息的响应
    /// </summary>
    public class GetPluginInfosResponse
    {
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="plugin">原始插件信息</param>
        public GetPluginInfosResponse(PluginInstance plugin)
        {
            this.Name = plugin.Name;
            this.Sha256 = plugin.Sha256;
            this.Version = plugin.Version;
            this.PluginFilePath = plugin.PluginFilePath;
            this.IsRelease = plugin.IsRelease;
            this.AllGrpcServices = plugin.AllGrpcServices.Select(item => item.Name).ToList();
            this.AllApi = plugin.AllApi.Select(item => item.Name).ToList();
            this.AllJobs = plugin.AllJobs.Select(item => item.Name).ToList();
        }
        /// <summary>
        /// 名称
        /// </summary>
        public string Name { get; init; } = "";
        /// <summary>
        /// 文件sha256
        /// </summary>
        public string Sha256 { get; init; } = "";
        /// <summary>
        /// 版本
        /// </summary>
        public Version Version { get; init; } = new();
        /// <summary>
        /// 插件文件地址
        /// </summary>
        public string PluginFilePath { get; init; } = "";
        /// <summary>
        /// 是否是发布版本
        /// </summary>
        public bool IsRelease { get; init; } = false;

        /// <summary>
        /// 所有的GRPC服务类型
        /// </summary>
        public List<string> AllGrpcServices { get; init; } = new();
        /// <summary>
        /// 所有的API服务
        /// </summary>
        public List<string> AllApi { get; init; } = new();
        /// <summary>
        /// 所有的Job服务
        /// </summary>
        public List<string> AllJobs { get; init; } = new();
    }
}
